package com.cscec5b.inspection.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConfigurationProperties(prefix = "app")
public class AppProperties {
    private long tokenTtlSeconds = 3600;
    private long maxClockSkewSeconds = 300;
    private boolean requireSignature = false;
    private int batchLimit = 1000;
    private int rateLimitPerMin = 600;
    private java.util.List<String> authExcludePaths =
            java.util.List.of("/auth/token","/.well-known/**","/ping/**",
                    "/api/user/login","/error","/swagger-ui/**","/v3/api-docs/**", "/api/**");
    private java.util.List<String> protectedPrefixes = java.util.List.of("/api/v1/**");
    public java.util.List<String> getProtectedPrefixes() { return protectedPrefixes; }
    public void setProtectedPrefixes(java.util.List<String> v) { this.protectedPrefixes = v; }

    public java.util.List<String> getAuthExcludePaths() { return authExcludePaths; }
    public void setAuthExcludePaths(java.util.List<String> v) { this.authExcludePaths = v; }

    public long getTokenTtlSeconds() { return tokenTtlSeconds; }
    public void setTokenTtlSeconds(long tokenTtlSeconds) { this.tokenTtlSeconds = tokenTtlSeconds; }
    public long getMaxClockSkewSeconds() { return maxClockSkewSeconds; }
    public void setMaxClockSkewSeconds(long maxClockSkewSeconds) { this.maxClockSkewSeconds = maxClockSkewSeconds; }
    public boolean isRequireSignature() { return requireSignature; }
    public void setRequireSignature(boolean requireSignature) { this.requireSignature = requireSignature; }
    public int getBatchLimit() { return batchLimit; }
    public void setBatchLimit(int batchLimit) { this.batchLimit = batchLimit; }
    public int getRateLimitPerMin() { return rateLimitPerMin; }
    public void setRateLimitPerMin(int rateLimitPerMin) { this.rateLimitPerMin = rateLimitPerMin; }
    public static class Upstream {  // 向上游系统返回数据
        private String baseUrl;
        private String receivePath;
        private String token;
        private int connectTimeoutMs = 5000;
        private int readTimeoutMs = 15000;
        // getters/setters

        public String getBaseUrl() {
            return baseUrl;
        }

        public void setBaseUrl(String baseUrl) {
            this.baseUrl = baseUrl;
        }

        public String getReceivePath() {
            return receivePath;
        }

        public void setReceivePath(String receivePath) {
            this.receivePath = receivePath;
        }

        public String getToken() {
            return token;
        }

        public void setToken(String token) {
            this.token = token;
        }

        public int getConnectTimeoutMs() {
            return connectTimeoutMs;
        }

        public void setConnectTimeoutMs(int connectTimeoutMs) {
            this.connectTimeoutMs = connectTimeoutMs;
        }

        public int getReadTimeoutMs() {
            return readTimeoutMs;
        }

        public void setReadTimeoutMs(int readTimeoutMs) {
            this.readTimeoutMs = readTimeoutMs;
        }
    }
    private Upstream upstream = new Upstream();
    public Upstream getUpstream() { return upstream; }
    public void setUpstream(Upstream u) { this.upstream = u; }
}
